package pers.goetboy.common.vaild;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 手机号校验
 */
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = PhoneValidator.class)
public @interface Phone {
    String message() default "请传入正确的手机号";

    /**
     * 手机号格式,支持号段:
     * 130-139
     * 145,147,149
     * 150-153,155-159
     * 166
     * 170,171,173,175-178
     * 180-189
     * 198,199
     * @return
     */
    String regex() default "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
